package com.company.testArithmetic;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016.8.21.
 */
public class Test304 {
    public static void procedure(ArrayList<Integer> L1, ArrayList<Integer> L2){
        ArrayList arrayList=new ArrayList();
        int point1=0;
        int point2=0;
        int z;

        int number;
        if (L1.get(point1)<L2.get(point2)){
            number=L1.get(point1);
            point1++;
            z=0;
        }else {
            number=L2.get(point2);
            point2++;
            z=1;
        }
        arrayList.add(number);

        while (point1<L1.size()&&point2<L2.size()){
            int n;
            if(L1.get(point1)<L2.get(point2)){
                n=L1.get(point1);
                point1++;
                if(n!=number||z==0){
                    arrayList.add(n);
                }
                z=0;
            }else {
                n=L2.get(point2);
                point2++;
                if(n!=number||z==1){
                    arrayList.add(n);
                }
                z=1;
            }

            number=n;
        }

        while (point1<L1.size()){
            arrayList.add(L1.get(point1));
            point1++;
        }

        while (point2<L2.size()){
            arrayList.add(L2.get(point2));
            point2++;
        }

        System.out.println(arrayList);
    }
}